<?php

/**
 * This is the model class for table "{{mba_friend}}".
 *
 * The followings are the available columns in table '{{mba_friend}}':
 * @property string $id
 * @property string $alumni_id
 * @property string $title
 * @property string $banner_url
 * @property string $content
 * @property string $ctime
 * @property string $mtime
 * @property string $dtime
 * @property string $status
 * @property string $is_del
 * @property string $zan_count
 * @property string $fav_count
 * @property string $is_hot
 */
class MbaFriend extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mba_friend}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('content', 'required'),
			array('alumni_id, ctime, mtime, dtime, zan_count, fav_count', 'length', 'max'=>10),
			array('title, banner_url', 'length', 'max'=>255),
			array('status, is_del, is_hot', 'length', 'max'=>1),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, alumni_id, title, banner_url, content, ctime, mtime, dtime, status, is_del, zan_count, fav_count, is_hot', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'alumni_id' => 'Alumni',
			'title' => 'Title',
			'banner_url' => 'Banner Url',
			'content' => 'Content',
			'ctime' => 'Ctime',
			'mtime' => 'Mtime',
			'dtime' => 'Dtime',
			'status' => 'Status',
			'is_del' => 'Is Del',
			'zan_count' => 'Zan Count',
			'fav_count' => 'Fav Count',
			'is_hot' => 'Is Hot',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('alumni_id',$this->alumni_id,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('banner_url',$this->banner_url,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('ctime',$this->ctime,true);
		$criteria->compare('mtime',$this->mtime,true);
		$criteria->compare('dtime',$this->dtime,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('is_del',$this->is_del,true);
		$criteria->compare('zan_count',$this->zan_count,true);
		$criteria->compare('fav_count',$this->fav_count,true);
		$criteria->compare('is_hot',$this->is_hot,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return MbaFriend the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
